import React from 'react';
import ReactDOM from 'react-dom';
import Dialog from './components/dialog'
class App extends React.Component {
    state = {
      flag:false
    }
    showFn= ()=>{
      this.setState({
        flag:true
      })
    }
    close = (bol)=>{
      this.setState({
        flag:bol
      })
    }
    ok =()=>{
      console.log('点击了OK')
      setTimeout(() => {
        this.close(false)
      }, 2000);
      
    }
    noOk=()=>{
      console.log('点击了noOK')
      this.close(false)
    }
    render() {
        let {flag} = this.state;
        return <div className=''>
          <button onClick={this.showFn}>展示弹框</button>
          {
            flag ?
            <Dialog 
            onClose={this.close}
            onSure={this.ok}
            onCancel={this.noOk}
            >
              <p>Some contents...</p>
              <p>Some contents...</p>
              <p>Some contents...</p>
              asdfgasdfgsdfg
            </Dialog>:
            null
          }
        </div>;
    }
}

ReactDOM.render(<App/>,document.getElementById('root'))